var prmoseHttp = require('../../utils/prmoseHttp.js');
var app = getApp();
Component({
  mixins: [],
  data: {
    imgSrc:'https://rhi0.xiyun.net/zhuandian/',
  },
  props: {
    isShow:{
      type:Boolean,
      value:true,
    },
  },
  didMount() {},
  didUpdate() {},
  didUnmount() {},
  methods: {
    onGoLogin(){
      //执行登录
    let that = this;
    my.getOpenUserInfo({
      success: function (res) {
        let data = JSON.parse(res.response).response
        prmoseHttp.publicRequest(prmoseHttp.apiAddress.login,{
          address:data.province + data.city,
          avatar:data.avatar,
          nickname:data.nickName,
          sex:(data.gender == '') ? 3 : data.gender,
        },1,'post').then(result => {
          if (result.code == 200) {
            that.props.onGoLogin();
          }
        }).catch(res => {
          console.log(res);
        });
      },
      fail: function (res) {
        my.showToast({
          content: '拒绝授权',
          type: 'none'
        });
      }
    });
    },
    onClose(){
      this.props.onClose();
    },

  },
});
